const router = require('koa-router')()
const Message = require('../class/message')
const { Fb } = require('../class/utils')

router.prefix('/')

// 添加留言
router.post('/createMes.do', async ctx => {
    const form = ctx.request.body
    ctx.body = await Fb.callback(Message.create(form))
})

// 获取留言列表
router.post('/getMesList.do', async ctx => {
    const form = ctx.request.body
    let nowPage = parseInt(form.nowPage) || 1
    let pageSize = parseInt(form.pageSize) || 9999999
    ctx.body = await Fb.callback(Message.select(form,nowPage,pageSize))
})
// 回复留言信息
router.post('/updateMes.do', async ctx => {
    const form = ctx.request.body
    ctx.body = await Fb.callback(Message.update(form))
})

// 删除留言
router.post('/deleteMes.do', async ctx => {
    const form = ctx.request.body
    ctx.body = await Fb.callback(Message.delete(form))
})

module.exports = router